/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bai2;

import java.io.File;
import java.util.jar.Attributes;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

/**
 *
 * @author ngadtt
 */
public class SaxProcessing extends DefaultHandler {

    static int count = 0;

    public static void main(String[] args) {
        if (args.length != 1) {
            System.out.println("hiiiiiiiiii");
            System.exit(1);
        }
        SaxProcessing saxObject = new SaxProcessing();
        SAXParserFactory spf = SAXParserFactory.newInstance();
        try {
            SAXParser parser = spf.newSAXParser();
            parser.parse(new File(args[0]), saxObject);
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    public void startElement(String namespaceUPI, String simpleName, String qualifiedName, Attributes attributeList) throws SAXException {
        if (qualifiedName.equals("users")) {
            count++;

        }
    }

    public void endDocument() throws SAXException {
        System.out.println(count + "hhhhhhhhhhhh");
    }
}
